<!-- 机构管理 -->

<!-- 项目管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">机构管理</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      bjtext="编辑/审核"
      :czFun="czFun"
      czWidth="250"
      ref="databale"
      :hidebj="true"
      :isshowSc="false"
      :isshowXz="false"
    ></dxtable>

    <n-modal
      v-model:show="showModal"
      preset="card"
      class="Stock-diagnosisxcxty"
      @close="guanbis"
    >
      <template #header>
        <div>添加课程</div>
      </template>
      <div>
        <iframe
          :src="
            'https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/case/kcgl/index.html#/pages/trainingInstitutions/addCourse?jigouId=' +
            jigouId
          "
        ></iframe>
      </div>
      <template #action>
        <div class="tr">
          <n-button @click="guanbis"> 关闭 </n-button>
        </div>
      </template>
    </n-modal>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { dxget, dxpost } from "../../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive } from "vue";
const databale = ref();
const jigouId = ref();
const showModal = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
const kxzczdf = [
  {
    label: "全部",
    value: "",
  },
  {
    label: "等待审核",
    value: 0,
  },
  {
    label: "审核中",
    value: 1,
  },
  {
    label: "认证通过",
    value: 2,
  },
  {
    label: "认证不通过",
    value: "3",
  },
];
let dataJson = [
  {
    title: "用户名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "phone",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "密码",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "paw",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "头像",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "img",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "机构名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "title",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "负责人姓名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "fzr",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "负责人电话",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "fzrphone",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  // {
  //   title: "机构简介",
  //   type: "textarea",
  //   val: "",
  //   icon: "dx-duohangwenben",
  //   span: 24,
  //   key: "jgjj",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  {
    title: "营业执照",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "yyzz",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "办学许可证",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "bxz",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "审核",
    type: "select",
    options: kxzczdf,
    icon: "dx-radiobox",
    val: "",
    key: "authentication",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      try {
        return kxzczdf.filter((a) => a.value === row.authentication)[0].label;
      } catch (e) {}
    },
  },

  // {
  //   title: "排序",
  //   width: 100,
  //   render: (row) => {
  //     row.sjk = "courseManagement"; //数据库
  //     row.databaseName = "mechanismUser"; //表名
  //     return h(sort, {
  //       row,
  //       onCallBack: () => {
  //         initeer();
  //       },
  //     });
  //   },
  // },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "cmechanismUserdel", //删除
  EditPermissionIdentifier: "cmechanismUserbj", // 编辑
  NewPermissionIdentifier: "cmechanismUserxz", // 新建
  ViewPermissionID: "cmechanismUserck", // 查看
};
const portUrl = "courseManagement/erqi/gjjxctr?qyId=" + localStorage.qyId;

let formJson = reactive([
  {
    title: "用户名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "phone",
    width: "",
    search: true,
    istable: true,
    required: true,
  },
  {
    title: "密码",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "paw",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "头像",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "img",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "机构名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "title",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "负责人姓名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "fzr",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "负责人电话",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "fzrphone",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "机构简介",
    type: "textarea",
    val: "",
    icon: "dx-duohangwenben",
    span: 24,
    key: "jgjj",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "营业执照",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "yyzz",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "办学许可证",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "bxz",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "审核",
    type: "radio",
    icon: "dx-radiobox",
    val: "",
    opt: [
      {
        label: "审核中",
        value: 1,
      },
      {
        label: "认证通过",
        value: 2,
      },
      {
        label: "认证不通过",
        value: "3",
      },
    ],
    span: 24,
    key: "authentication",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            showModal.value = true;
            jigouId.value = row.id;
          },
        },
        "添加课程"
      ),
    ];
  },
};

// 获取字典内容
// const xtgxxmfl = async () => {
//   const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xtgxxmfl' })
//   dataJson[2].options = [
//     {
//       label: "全部",
//       value: ""
//     },
//     ...data
//   ]
//   formJson[2].options = data
//   xmlxSelect.value = data
//   console.log(data);
// }
// xtgxxmfl()

const guanbis = () => {
  showModal.value = false;
  initeer();
};
</script>
<style scoped></style>
